const express = require('express');
const router = express.Router()
const controller = require('../controller/FileSlice')

const multer = require("multer");

const chunkPath = './chunks'
const chunkStorage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, chunkPath)  //  上传文件保存的路径
  },
  filename: function (req, file, cb) {
    cb(null, 'chunks-' + file.originalname) //  上传文件的名称
  }
})
const chunkServer = multer({ storage: chunkStorage }) //  上传文件的中间件

router.get('/checkChunk', controller.checkChunk)
router.post('/uploadChunk', chunkServer.single('file'), controller.uploadChunk)
router.post('/mergeChunk', controller.mergeChunk)

module.exports = router
